package cn.guet.tourism.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import cn.guet.tourism.base.BaseController;
import cn.guet.tourism.entity.Goods;
import cn.guet.tourism.service.IGoodsService;

/**
 * 商品控制器
 *
 * @author SAGITTAR
 */
@Controller
public class GoodsController extends BaseController<IGoodsService, Goods> {

	@RequestMapping(value = "/from")
	public String from(RedirectAttributes attributes) {
		attributes.addAttribute("111", "222");
		return redirectTo("to");
	}

	@ResponseBody
	@RequestMapping(value = "/to")
	public String to(@RequestParam(value = "111") String param) {
		return String.format("{\"value\": \"%s\"}", param);
	}

	@RequestMapping(value = "/this")
	public String redirectTo() {
		return redirectTo("/index");
	}

	@RequestMapping(value = "/index")
	public String index(Model model) {
		model.addAttribute("key", GoodsController.class.getSimpleName());
		return "index";
	}
}
